﻿var lookup = {};
var change = function(token) {
    if (token) {
        //loadExample(token, lookup[token] || "-");
    } else {
        MainTab.setActiveTab(0);
    }
};

var addToken = function(el, tab) {
    if (tab.autoLoad && tab.autoLoad.url) {
        var host = window.location.protocol + "//" + window.location.host + "/Examples",
            token = tab.autoLoad.url.substr(host.length);

        if (!Ext.isEmpty(token)) {
            History1.add(token);
        }
    } else {
        History1.add("");
    }
};
var addTab = function(tabPanel, id, url, title, icon, menuPanel) {
    var tab = tabPanel.getComponent(id);

    if (!tab) {
        tab = tabPanel.add({
            id: id,
            title: title,
            iconCls: icon,
            closable: true,
            border: false,
            autoLoad: {
                showMask: true,
                url: url,
                mode: "iframe",
                maskMsg: "Loading " + title + "..."
            }
        });

        tab.on("activate", function() {
        var item = menuPanel.menu.items.get(id + "_item");

            if (item) {
                menuPanel.setSelection(item);
            }
        }, this);
    }

    tabPanel.setActiveTab(tab);
}